package com.yang.dao;

import com.yang.entity.NoteRole;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import javax.management.relation.Role;
import java.util.List;

/**
 * 角色表(NoteRole)表数据库访问层
 *
 * @author yangdacheng
 * @since 2022-03-02 19:11:02
 */
@Mapper
@Repository
public interface NoteRoleDao {

    /**
     * 添加新的角色
     * @param noteRole
     * @return
     */
    @Insert("INSERT INTO noteRole VALUES(#{roleId},#{roleName},#{roleNameZH})")
    Boolean insertNoteRole(NoteRole noteRole);

    /**
     * 根据编号删除对应的角色
     * @param noteRID
     * @return
     */
    @Delete("DELETE FROM noteRole WHERE roleID = #{noteRID}")
    Boolean delNoteRole(String noteRID);

    /**
     * 查询所有的角色
     * @return
     */
    @Results(value = {
            @Result(column = "roleID",property = "roleId",id = true),
            @Result(column = "roleName",property = "roleName"),
            @Result(column = "roleNameZH",property = "roleNameZH"),
    },id = "noteRoleMapper")
    @Select("SELECT * FROM noteRole")
    List<NoteRole> queryAllNoteRole();

    /**
     * 根据编号获取对应的角色
     * @param noteRID
     * @return
     */
    @Select("SELECT * FROM noteRole WHERE roleID = #{noteRID}")
    @ResultMap(value = "noteRoleMapper")
    NoteRole queryByRID(String noteRID);
}